package com.potato369.cryptEureka.config;

import cn.hutool.core.util.StrUtil;
import com.baidu.aip.contentcensor.AipContentCensor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class BaiduAipConfig {

    @Value("${com.potato369.baidu-api.app-id}")
    private String appid;

    @Value("${com.potato369.baidu-api.api-key}")
    private String ak;

    @Value("${com.potato369.baidu-api.secret-key}")
    private String sk;

    @Bean
    public AipContentCensor getAipContentCensor() {
        AipContentCensor client = new AipContentCensor(
                StrUtil.trimToEmpty(appid),
                StrUtil.trimToEmpty(ak),
                StrUtil.trimToEmpty(sk));
        client.setConnectionTimeoutInMillis(2000);
        client.setSocketTimeoutInMillis(6000);
        return client;
    }
}
